package pb2;
import java.util.Stack;
import java.util.EmptyStackException;

public class DoubleStackQueue<Elem> implements myQueue<Elem>
{
	private Stack<Elem> inbox = new Stack<Elem>();
	private Stack<Elem> outbox = new Stack<Elem>();


public void offer(Elem element) {
	inbox.push(element);
}


public Elem peek() {
	if (outbox.empty()) {
        while (!inbox.empty()) {
           outbox.push(inbox.pop());
        }
    }
    return outbox.peek();
}


public Elem poll() {
	if (outbox.empty()) {
        while (!inbox.empty()) {
           outbox.push(inbox.pop());
        }
    }
    return outbox.pop();
}
}
